import { VueQueryPlugin } from '@tanstack/vue-query'
import { createSSRApp } from 'vue'
import App from './App.vue'
import { requestInterceptor } from './http/interceptor'
import { routeInterceptor } from './router/interceptor'
// import { UniErrorSDK } from '@logwisdomhub/uniapp-error-sdk'

import store from './store'
import '@/style/index.scss'
import 'virtual:uno.css'

export function createApp() {
  const app = createSSRApp(App)
  app.use(store)
  app.use(routeInterceptor)
  app.use(requestInterceptor)
  app.use(VueQueryPlugin)

  // 创建 SDK 实例并初始化
  // const errorSDK = new UniErrorSDK({
  //   apiKey: 'lwh_3df88d925d475551ed84c542d1fd129a362d590037fca481f65f8c9110b91531',  // 注意：参数名是 apiKey，不是 apikey
  //   baseURL: 'http://localhost:8001',
  //   projectId: '6',  // 注意：参数名是 projectId，不是 projectID
  //   enableConsoleLog: true,
  //   enableAutoReport: true,
  //   maxRetryCount: 3, 
  //   retryDelay: 1000
  // })

  // // 异步初始化 SDK
  // errorSDK.init().catch(error => {
  //   console.error('SDK 初始化失败:', error)
  // })

  return {
    app,
  }
}
